<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    console.log(Math.max(1,8,55));//最大值
    console.log(Math.PI);//圆周率
    console.log(Math.abs('-1'));//隐式转换 会把字符串型转换为数字型
    console.log(Math.floor(1.9));//向上取整
    console.log(Math.ceil(1.1));//向下取整
    console.log(Math.round(1.5));//四舍五入 如果是负数的话就会向下取整
    console.log(Math.random());//随机小数   取得到0取不到1
    function getRandom(min,max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    console.log(getRandom(1,100));
    var arr = ['张三','李四','王五','陈六'];
    console.log(arr[getRandom(0,arr.length - 1)]);
    var random = getRandom(1,10);
    while (true) {
        var num = prompt('1-10之间的数字');
        if (num > random){
            alert('你猜大了');
        } else if (num < random){
            alert('你猜小了');
        } else {
            alert('你猜对啦！');
            break;
        }
    }
</script>
<body>

</body>
</html>